package gtkwire.widget;

import gtkwire.*;

public class GtkAlignment extends GtkBin
{
	private double xalign;
	private double yalign;
	private double xscale;
	private double yscale;

/*
In the end, size allocation in GTK+ is utterly simple:

Phase 1: "Please ask your children how much space they need, add in any space you need yourself and tell me how much that is"

Phase 2: "OK, you have this much space, please divide between yourself and your children"

All expand and fill do is determine how a hbox/vbox makes that division in phase 2. 

Q: I've come to believe that the interaction between the GtkAlignment object and the EXPAND and FILL flags isn't working...
A: There is no interaction. The GtkAlignment container positions and scales it's child within the space allocated to the GtkAlignment.
*/
	public GtkAlignment()
	{
		super();

		this.widgetType = WT_GtkAlignment;

		this.xalign = xalign;
		this.yalign = yalign;
		this.xscale = xscale;
		this.yscale = yscale;

		gtkCreate();
	}

	public GtkAlignment( String name, GladeKey key )
	{
		super( name, key );

		this.widgetType = WT_GtkAlignment;

		this.xalign = xalign;
		this.yalign = yalign;
		this.xscale = xscale;
		this.yscale = yscale;
	}

	protected String[] getCreateData()
	{
		double[] data = getAlignArr();
		String[] msg = { 	Double.toString( data[ 0 ] ),
					Double.toString (data[ 1 ] ),
					Double.toString( data[ 2 ] ),
					Double.toString( data[ 3 ] ) };
		return msg;
	}

	private double[] getAlignArr()
	{
		double[] data = new double[ 4 ];
		data[ 0 ] = xalign;
		data[ 1 ] = yalign;
		data[ 2 ] = xscale;
		data[ 3 ] = yscale;
		return data;
	}

	public void setAlignment(double xalign, double yalign, double xscale,double yscale)
	{
		this.xalign = xalign;
		this.yalign = yalign;
		this.xscale = xscale;
		this.yscale = yscale;

		app().sendCommand( name, GTKWireCommand.SET_ALIGNMENT, getAlignArr());
	}

	public void setPadding( int padding_top, int padding_bottom, int padding_left, int padding_right)
	{	
		int[] msg = { padding_top, padding_bottom, padding_left, padding_right };
		app().sendCommand( name, GTKWireCommand.SET_PADDING, msg );
	}

}//end class